package com.wxy.demo.dao;

import com.wxy.demo.entity.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author wxy
 * @Date 19-8-19 上午10:02
 * @Description TODO
 **/
@Repository
public interface UserRepository extends JpaRepository<User, Long>, JpaSpecificationExecutor<User> {

    User findByUserName(String userName);

    Page<User> findAllByUserName(String userName, Pageable pageable);

    @Query(nativeQuery = true, value = "select * from t_user where user_name = :userName")
    List<User> findListByUserName(String userName);

    @Query("select u from User u where u.userName = :userName")
    List<User> findListByUserName1(String userName);

    List<User> findByUserNameLike(String userName);
}